<?
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header("Cashe-Control: no-cashe, must-revalidate");
Header("Pragma: no-cashe");
Header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");

if(isset($SQL)){  
//	Header("Content-type: image/jpeg");
} else {
	printf("This URL for internal use only !");
	exit();
}

require("includes.php");

print("<META>\n");
printf("<DATE>%s</DATE>\n",Str2Hex(gmdate("D, d M Y H:i:s")));
if (@$SQL) {
	printf("<REQUEST=SQL>");
	printf(Hex2Str($SQL));
	printf("</REQUEST>\n");
}
db_prepare($db_host,$db_name,$db_login,$db_password);

$rs = mysql_query(Hex2Str($SQL));

$err = mysql_errno();
if($err != 0) {
	printf("<ERROR=%s>",$err);
	printf("%s",Str2Hex(mysql_error()));
	printf("</ERROR>\n");
} else {
	printf("<ERROR=%s>",$err);
	printf("%s",Str2Hex("OK"));
	printf("</ERROR>\n");
}

if($err == 0) {
	if((isset($need_response))&&$need_response==1){  
              	printf("<TABLE>\n");
              	printf("<FIELDS=%d>",mysql_num_fields($rs));
		for($i=0; $i<mysql_num_fields($rs); $i++) {
                	printf("<FIELD=%d>",$i);	              		
			printf(Str2Hex(mysql_field_name($rs,$i)));
	              	printf("</FIELD=%d>",$i);
		}
              	printf("</FIELDS>\n");
		for($i=0; $i<mysql_num_rows($rs); $i++) {
                	printf("<ROW=%d>",$i);
			$f = mysql_fetch_array($rs);
		       	for ($j=0; $j<mysql_num_fields($rs); $j++) {
	                	printf("<COLUMN=%d>",$j);
				printf("%s",Str2Hex($f[$j]));
	                	printf("</COLUMN=%d>\n",$j);
		        }
                	printf("</ROW=%d>\n",$i);
		};
              	printf("</TABLE>\n");
	};
};
print("</META>");
db_close();
?>
